package hos.retrofit;

import java.io.IOException;

/**
 * <p>Title: HiCall </p>
 * <p>Description:  </p>
 * <p>Company: www.mapuni.com </p>
 *
 * @author : 蔡俊峰
 * @version : 1.0
 * @date : 2023-02-23 14:40
 */
public interface RetrofitCall<T> extends Cloneable {
    T execute() throws IOException;

    void enqueue(RetrofitCallback<T> callback);

    /**
     * Returns true if this call has been either {@linkplain #execute() executed} or {@linkplain
     * #enqueue(RetrofitCallback) enqueued}. It is an error to execute or enqueue a call more than once.
     */
    boolean isExecuted();

    /**
     * Cancel this call. An attempt will be made to cancel in-flight calls, and if the call has not
     * yet been executed it never will be.
     */
    void cancel();

    /**
     * True if {@link #cancel()} was called.
     */
    boolean isCanceled();

    /**
     * Create a new, identical call to this one which can be enqueued or executed even if this call
     * has already been.
     */
    RetrofitCall<T> clone();

    interface Factory {
        <T> RetrofitCall<T> newCall(RetrofitRequest request);
    }

}
